<script setup lang="tsx">
/**
 *  销售发货单-选源单
 */
import {nextTick, ref} from "vue"
import {definePageModel, PageModel} from "@/frame/view/layout/page-model/constructor.ts";
import {defineDialogForm, DialogForm} from "@/frame/components/base/dialog-form/constructor.ts";

/**
 * 定义emit
 */
const emit = defineEmits<{
  (e: "confirm", data: any): void
}>()

/**
 * 弹窗配置
 */
const dialogFormRef = ref()
const dialogFormConfig = defineDialogForm({
  width: "1200px",
  title: "销售发货单选源单"
})
/**
 * 页面实例
 */
const pageModelRef = ref()
const config = definePageModel<any>({
  url: "/api/SaleOrder/source",
  table: {
    page: {
      enable: true,
      pageSize: 20
    },
    props: {
      stripe: false,
      border: false
    },
    operation: {
      width: 80,
      props: {
        fixed: "right"
      },
      els: [
        {
          eType: "el-button",
          label: "选择",
          event: "select",
          props: {
            type: "primary",
            link: true
          },
          hide: false
        }
      ]
    },
    els: [
      {
        label: "销售订单号",
        prop: "code",
        minWidth: 120
      },
      {
        label: "流转卡号",
        prop: "cardNo",
        minWidth: 120
      },
      {
        label: "客户编码",
        prop: "customerCode",
        minWidth: 120
      },
      {
        label: "客户名称",
        prop: "customerName",
        minWidth: 120
      },
      {
        label: "客户手机号",
        prop: "customerPhone",
        minWidth: 120
      },
      {
        label: "创建时间",
        prop: "createTime",
        minWidth: 120
      }
    ]
  }
})

/**
 * 显示
 */
const show = () => {
  nextTick(() => {
    dialogFormRef.value.show()
  })
}

/**
 * 提交
 */
const handleSelect = (row: any) => {
  emit("confirm", row)
  dialogFormRef.value.close()
}

/**
 * 暴露
 */
defineExpose({
  show
})
</script>

<template>
  <DialogForm ref="dialogFormRef" :dialogFormModel="dialogFormConfig">
    <template #default>
      <div style="display: flex;height: 500px;">
        <PageModel ref="pageModelRef" :PageModel="config" @select="handleSelect"/>
      </div>
    </template>
  </DialogForm>
</template>

<style scoped lang="scss">

</style>